home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Printing / PrintPage.cp < prev    next >
Text File  |  2000-06-23  |  764b  |  54 lines

  1. // PrintPage.cp
  2.  
  3. #ifndef PrintPage_h
  4. #include "PrintPage.h"
  5. #endif
  6. #ifndef Assert_h
  7. #include "Assert.h"
  8. #endif
  9. #ifndef PrintingError_h
  10. #include "PrintingError.h"
  11. #endif
  12.  
  13. bool PrintPage::pageExists = false;
  14.  
  15. PrintPage::PrintPage()
  16.   : port( 0 )
  17.   {
  18.     Assert( !pageExists );
  19.     pageExists = true;
  20.   }
  21.  
  22. PrintPage::~PrintPage()
  23.   {
  24.     if ( port != 0 )
  25.       {
  26.         PrClosePage( port );
  27.         DebugOSError( PrError() );
  28.       }
  29.     
  30.     Assert( pageExists );
  31.     pageExists = false;
  32.   }
  33.  
  34. void PrintPage::Start( TPrPort& thePort )
  35.   {
  36.     Assert( port == 0 );
  37.  
  38.     PrOpenPage( &thePort, 0 );
  39.     ThrowPrintingError( PrError() );
  40.     
  41.     port = &thePort;
  42.   }
  43.  
  44. void PrintPage::End()
  45.   {
  46.     Assert( port != 0 );
  47.     
  48.     TPrPort *thePort = port;
  49.     port = 0;
  50.     
  51.     PrClosePage( thePort );
  52.     ThrowPrintingError( PrError() );
  53.   }
  54.